Method and apparatus for measuring distance using vehicle-mounted camera, storage medium, and electronic device

ABSTRACT

The present disclosure relates to a method and an apparatus for measuring a distance using a vehicle-mounted camera, a storage medium, and an electronic device. The method includes: calibrating a camera based on camera calibration images to obtain a camera parameter; detecting parallel lane lines to obtain a vanishing point of the parallel lane lines according to the detected parallel lane lines; calculating a pitch angle of the camera according to the camera parameter and the vanishing point; determining information of an object to be detected in an image captured by the camera; and calculating a distance from the object to be detected to the camera and a size of the object to be detected according to the information of the object to be detected, the pitch angle of the camera, and the camera parameter.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a § 371 national phase application of InternationalApplication No. PCT/CN2018/074821, filed on Jan. 31, 2018, which isbased upon and claims priority to Chinese Patent Application No.201710509281.7, titled “METHOD AND APPARATUS FOR MEASURING DISTANCEUSING VEHICLE-MOUNTED CAMERA, STORAGE MEDIUM, AND ELECTRONIC DEVICE” andfiled on Jun. 28, 2017, the entire contents of which are incorporatedherein by reference.

TECHNICAL FIELD

The present disclosure relates to the field of distance measurementtechnologies and, more particularly, to a method and an apparatus formeasuring a distance using a vehicle-mounted camera, a storage medium,and an electronic device.

BACKGROUND

With the development of the economy, the number of vehicles on road isincreasing. The frequent occurrence of traffic accidents may likely becaused by drivers' misjudgment to distances between vehicles. Therefore,it is important to control the distances between vehicles or distancesbetween vehicles and pedestrians. In vehicle-mounted auxiliary systems,in order to provide accurate forward collision warning or pedestriancollision warning, it is necessary to measure distances to and sizes offorward vehicles and pedestrians to ensure whether to raise an alarm.Typically, the auxiliary system is only provided with one monocularcamera. However, it is not sufficient to determine a distance to anobject based on an image captured only using the monocular camera.Considering that road surface is usually horizontal, and objects to bedetected such as the vehicles or pedestrians are close to the roadsurface, the distance between an object in the image and a camera aswell as the size of the object may be determined based on geometriccoordinate calculation.

At present, to calculate the distance between an object and a camera andthe size of the object, it is usually necessary to determine an angle ofthe camera and a location of a vanishing point of the road surface.However, in some technologies, a gyroscope is employed to determine theangle of the camera. In this case, the gyroscope needs to beadditionally installed in the auxiliary system. In some othertechnologies, the location of the vanishing point of the road surfaceneeds to be specified by manual labeling. Actual operations of thesetechnologies are cumbersome, and thus, a convenient method for measuringa distance using a vehicle-mounted camera is needed.

It is to be noted that the above information disclosed in thisBackground section is only for enhancement of understanding of thebackground of the present disclosure and therefore it may containinformation that does not form the related art that is already known toa person of ordinary skill in the art.

SUMMARY

According to an aspect of the present disclosure, there is provided amethod for measuring a distance using a vehicle-mounted camera.

The method for measuring a distance using a vehicle-mounted cameraincludes: calibrating a camera based on camera calibration images toobtain a camera parameter; detecting parallel lane lines to obtain avanishing point of the parallel lane lines according to the detectedparallel lane lines; calculating a pitch angle of the camera accordingto the camera parameter and the vanishing point; determining informationof an object to be detected in an image captured by the camera; andcalculating a distance from the object to be detected to the camera anda size of the object to be detected according to the information of theobject to be detected, the pitch angle of the camera, and the cameraparameter.

In an exemplary embodiment of the present disclosure, the cameracalibration images are at least three images obtained by capturing animage by the camera at different angles and locations.

In an exemplary embodiment of the present disclosure, calibrating thecamera calibration images includes: calibrating the camera calibrationimages using a Zhang Zhengyou calibration algorithm.

In an exemplary embodiment of the present disclosure, the detectingparallel lane lines includes: capturing an image containing the parallellane lines; filtering the image containing the parallel lane lines byusing a gradient edge detection operator to generate a gradient image;determining an optimal threshold of the gradient image by using athreshold determination algorithm, and performing binarizationprocessing on the gradient image to obtain an edge pattern; detecting astraight line in the edge pattern using a feature extraction algorithm;and determining two straight lines adjacent to each other and havingopposite deflection directions with respect to a height direction of theimage as the parallel lane lines.

In an exemplary embodiment of the present disclosure, the object to bedetected is represented as a rectangular window. The determining ofinformation of an object to be detected in an image captured by thecamera includes: determining a coordinate of an arbitrary point of therectangular window corresponding to the object to be detected in theimage captured by the camera and a width and a height of the rectangularwindow.

In an exemplary embodiment of the present disclosure, the camera isinstalled directly in front of a vehicle.

In an exemplary embodiment of the present disclosure, a coordinate ofthe vanishing point in the image captured by the camera is denoted as(u₀, v₀), and the pitch angle of the camera is calculated based on aformula as below:

$\varphi = {\arctan\left( \frac{c_{v} - v_{0}}{f_{v}} \right)}$

wherein φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, and c_(v) represents a location coordinateof an optical center of the camera head.

In an exemplary embodiment of the present disclosure, the size of theobject to be detected includes a height and a width of the object to bedetected.

In an exemplary embodiment of the present disclosure, the distance fromthe object to be detected to the camera is calculated based on a formulaas below:

$D = \frac{{f_{v}h_{c}} + {{h_{c}\left( {c_{v} - v_{t\; 2}} \right)}\mspace{14mu}\tan\mspace{14mu}(\varphi)}}{v_{t\; 2} - v_{0}}$

wherein D represents the distance from the object to be detected to thecamera, φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, c_(v) represents a location coordinate ofan optical center of the camera head, and a coordinate of a midpoint ofa lower side of the rectangular window in the image is denoted as(u_(t2), v_(t2)) and a corresponding spatial point coordinate is denotedas (x_(t2), D, −h_(c)), and a coordinate of the vanishing point in theimage captured by the camera is denoted as (u₀, v₀).

In an exemplary embodiment of the present disclosure, the height of theobject to be detected is calculated based on a formula as below:

$H = \frac{h_{t}\left( {D + {h_{c}\mspace{14mu}\tan\mspace{14mu}(\varphi)}} \right)}{f_{v} + {\left( {c_{v} - v_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$

wherein H represents the height of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, h_(t) represents the height of therectangular window, f_(v) represents a focal length of a camera head ofthe camera, c_(v) represents a location coordinate of an optical centerof the camera head, the coordinate of the arbitrary point is denoted as(u_(t), v_(t)), and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).

In an exemplary embodiment of the present disclosure, the width of theobject to be detected is calculated based on a formula as below:

$W = {\frac{w_{t}}{f_{u}}\left( {{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \right)}$

wherein W represents the width of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, f_(u) represents a focal length of a camerahead of the camera, w_(t) represents the width of the rectangularwindow, and a coordinate of a midpoint of a lower side of therectangular window in the image are denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).

According to another aspect of the present disclosure, there is providedan apparatus for measuring a distance using a vehicle-mounted camera,which includes: a camera calibrator, configured to calibrate a camerabased on camera calibration images to obtain a camera parameter; avanishing point obtainer, configured to detect parallel lane lines toobtain a vanishing point of the parallel lane lines according to thedetected parallel lane lines; a pitch angle calculator, configured tocalculate a pitch angle of the camera according to the camera parameterand the vanishing point; an object to be detected determiner, configuredto determine information of an object to be detected in an imagecaptured by the camera; and a distance detector, configured to calculatea distance from the object to be detected to the camera and a size ofthe object to be detected according to the information of the object tobe detected, the pitch angle of the camera, and the camera parameter.

In an exemplary embodiment of the present disclosure, the cameracalibration images are at least three images obtained by capturing animage by the camera at different angles and locations.

In an exemplary embodiment of the present disclosure, calibrating thecamera calibration images includes: calibrating the camera calibrationimages using a Zhang Zhengyou calibration algorithm.

In an exemplary embodiment of the present disclosure, the detectingparallel lane lines includes: capturing an image containing the parallellane lines; filtering the image containing the parallel lane lines byusing a gradient edge detection operator to generate a gradient image;determining an optimal threshold of the gradient image by using athreshold determination algorithm, and performing binarizationprocessing on the gradient image to obtain an edge pattern; detecting astraight line in the edge pattern using a feature extraction algorithm;and determining two straight lines adjacent to each other and havingopposite deflection directions with respect to a height direction of theimage as the parallel lane lines.

In an exemplary embodiment of the present disclosure, the object to bedetected is represented as a rectangular window. The determining ofinformation of an object to be detected in an image captured by thecamera includes: determining a coordinate of an arbitrary point of therectangular window corresponding to the object to be detected in theimage captured by the camera and a width and a height of the rectangularwindow.

In an exemplary embodiment of the present disclosure, the camera isinstalled directly in front of a vehicle.

In an exemplary embodiment of the present disclosure, a coordinate ofthe vanishing point in the image captured by the camera is denoted as(u₀, v₀), and the pitch angle of the camera is calculated based on aformula as below:

$\varphi = {\arctan\left( \frac{c_{v} - v_{0}}{f_{v}} \right)}$

wherein φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, and c_(v) represents a location coordinateof an optical center of the camera head.

In an exemplary embodiment of the present disclosure, the size of theobject to be detected includes a height and a width of the object to bedetected.

In an exemplary embodiment of the present disclosure, the distance fromthe object to be detected to the camera is calculated based on a formulaas below:

$D = \frac{{f_{v}h_{c}} + {{h_{c}\left( {c_{v} - v_{t\; 2}} \right)}\mspace{14mu}\tan\mspace{14mu}(\varphi)}}{v_{t\; 2} - v_{0}}$

wherein D represents the distance from the object to be detected to thecamera, φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, c_(v) represents a location coordinate ofan optical center of the camera head, and a coordinate of a midpoint ofa lower side of the rectangular window in the image is denoted as(u_(t2), v_(t2)) and a corresponding spatial point coordinate is denotedas (x_(t2), D, −h_(c)), and a coordinate of the vanishing point in theimage captured by the camera is denoted as (u₀, v₀).

In an exemplary embodiment of the present disclosure, the height of theobject to be detected is calculated based on a formula as below:

$H = \frac{h_{t}\left( {D + {h_{c}\mspace{14mu}\tan\mspace{14mu}(\varphi)}} \right)}{f_{v} + {\left( {c_{v} - v_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$

wherein H represents the height of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, h_(t) represents the height of therectangular window, f_(v) represents a focal length of a camera head ofthe camera, c_(v) represents a location coordinate of an optical centerof the camera head, the coordinate of the arbitrary point is denoted as(u_(t), v_(t)), and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).

In an exemplary embodiment of the present disclosure, the width of theobject to be detected is calculated based on a formula as below:

$W = {\frac{w_{t}}{f_{u}}\left( {{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \right)}$

wherein W represents the width of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, f_(u) represents a focal length of a camerahead of the camera, w_(t) represents the width of the rectangularwindow, and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).

According to an aspect of the present disclosure, there is provided astorage medium, which stores a computer program. When the computerprogram is executed by a processor, the method for measuring a distanceusing a vehicle-mounted camera according to any one of the aboveembodiments is implemented.

According to an aspect of the present disclosure, there is provided anelectronic device, which includes: a processor; and a memory, configuredto store executable instructions of the processor. The processor isconfigured to perform the method for measuring a distance using avehicle-mounted camera according to any one of the above embodiments byexecuting the executable instructions.

It is to be understood that the above general description and thedetailed description below are merely exemplary and explanatory, and donot limit the present disclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings herein are incorporated in and constitute apart of this specification, illustrate embodiments conforming to thepresent disclosure and, together with the description, serve to explainthe principle of the present disclosure. Understandably, theaccompanying drawings in the following description show merely someembodiments of the present disclosure, and persons of ordinary skill inthe art may still derive other drawings from these accompanying drawingswithout creative efforts. In the drawings:

FIG. 1 schematically illustrates a flowchart of a method for measuring adistance using a vehicle-mounted camera according to an exemplaryembodiment of the present disclosure;

FIG. 2 schematically illustrates an exemplary image captured by avehicle-mounted camera;

FIG. 3 illustrates a schematic diagram of detecting parallel lane linesaccording to the exemplary image as shown in FIG. 2;

FIG. 4 illustrates a schematic diagram of determining a vanishing pointof the parallel lane lines according to the exemplary image as shown inFIG. 2;

FIG. 5 illustrates a schematic diagram of determining an object to bedetected according to the exemplary image as shown in FIG. 2;

FIG. 6 schematically illustrates a flowchart of concrete implementationof a method for measuring a distance using a vehicle-mounted cameraaccording to an exemplary embodiment of the present disclosure;

FIG. 7 schematically illustrates a block diagram of an apparatus formeasuring a distance using a vehicle-mounted camera according to anexemplary embodiment of the present disclosure;

FIG. 8 illustrates a schematic diagram of a storage medium according toan exemplary embodiment of the present disclosure; and

FIG. 9 schematically illustrates a block diagram of an electronic deviceaccording to an exemplary embodiment of the present disclosure.

DETAILED DESCRIPTION

Exemplary embodiments will be described more comprehensively byreferring to the accompanying drawings now. However, the exemplaryembodiments can be embodied in many forms and should not be construed asbeing limited to the embodiments set forth herein; rather, theseembodiments are provided so that this disclosure will be made thoroughand complete, and the concept of exemplary embodiments will be fullyconveyed to those skilled in the art. Furthermore, the describedfeatures, structures, or characteristics may be combined in any suitablemanner in one or more embodiments. In the following description,numerous specific details are provided to provide a thoroughunderstanding of the embodiments of the present disclosure. Thoseskilled in the art will recognize, however, that the technical solutionof the present disclosure may be practiced without one or more of thespecific details described, or that other methods, components, devices,steps, etc., may be employed. In other instances, well-known technicalsolutions are not shown or described in detail to avoid obscuringaspects of the present disclosure.

In addition, the accompanying drawings are merely exemplary illustrationof the present disclosure, and are not necessarily drawn to scale. Thesame reference numerals in the drawings denote the same or similarparts, and thus repeated description thereof will be omitted. Someblocks shown in the figures are functional entities and not necessarilyto be corresponding to a physically or logically individual entities.These functional entities may be implemented in software form, orimplemented in one or more hardware modules or integrated circuits, orimplemented in different networks and/or processor apparatuses and/ormicrocontroller apparatuses.

The flowcharts as shown in the accompanying drawings are merelyexemplary description instead of necessarily including all the steps.For example, some steps may be further divided, while some steps may becombined or partly combined. Therefore, the actual execution sequencesmay be changed according to the actual conditions.

At present, a camera may be used to photograph surroundings of avehicle, and captured images may be analyzed to determine distancesbetween vehicles, distances between the vehicle and pedestrians, anddistances between the vehicle and other obstacles, and sizes of thevehicles, the pedestrians or other obstacles displayed in the images mayalso be determined to facilitate drivers to make safety judgment.

In the following description, the present disclosure is described bytaking an example where a camera is installed directly in front of avehicle, and FIG. 2 schematically illustrates an exemplary imagecaptured by the camera. However, it is to be understood that thedistance measurement can also be implemented through the contentrecorded in the solution even though the camera is installed at anotherlocation of the vehicle. In addition, a yaw angle of the camera isapproximately equal to zero, and a height h_(c) from the camera to theground may be measured using a ruler.

FIG. 1 schematically illustrates a flowchart of a method for measuring adistance using a vehicle-mounted camera according to an exemplaryembodiment of the present disclosure. Referring to FIG. 1, the methodfor measuring a distance using a vehicle-mounted camera may includefollowing steps:

step S10: calibrating a camera based on camera calibration images toobtain a camera parameter;

step S20: detecting parallel lane lines to obtain a vanishing point ofthe parallel lane lines according to the detected parallel lane lines;

step S30: calculating a pitch angle of the camera according to thecamera parameter and the vanishing point;

step S40: determining information of an object to be detected in animage captured by the camera; and

step S50: calculating a distance from the object to be detected to thecamera and a size of the object to be detected according to theinformation of the object to be detected, the pitch angle of the camera,and the camera parameter.

In the method for measuring a distance using a vehicle-mounted cameraaccording to this exemplary embodiment of the present disclosure, thepitch angle of the camera is automatically calculated based on theobtained camera parameter and the automatically detected parallel lanelines, and the objective of accurately measuring the distance to and thesize of the object to be detected is achieved based on the informationof the object to be detected. In addition, in the process of measuring adistance according to this solution, no manual intervention is required,and thus this method is convenient and easy to be implemented.

Each step of the method for measuring a distance using a vehicle-mountedcamera according to this exemplary embodiment of the present disclosurewill be described in detail below.

In Step S10, a camera is calibrated based on camera calibration imagesto obtain a camera parameter.

In an exemplary embodiment of the present disclosure, an internalparameter matrix of the camera may be denoted as:

$\begin{bmatrix}f_{u} & 0 & c_{u} \\0 & f_{v} & c_{v} \\0 & 0 & 1\end{bmatrix}\quad$

wherein f_(u) and f_(v) represent a focal length of a camera head, andc_(u) and c_(v) represent a location coordinate of an optical center ofthe camera head. By way of calibration, f_(u), f_(v), c_(u) and c_(v)may be calculated out.

The calibration process of the camera may be completed either offline oronline. For example, a linear calibration method (e.g., Faugerascalibration method, etc.), a nonlinear optimization calibration method(e.g., Levenberg-Marquadt algorithm, etc.), a two-step calibrationmethod (e.g., Tsai two-step method, Zhang Zhengyou calibrationalgorithm, etc.), or other methods may be employed to calculate f_(u),f_(v), c_(u) and c_(v), which are not particularly limited in thisexemplary embodiment.

Taking the Zhang Zhengyou calibration algorithm as an example, an imagein which a checkerboard is drawn may be placed in front of the camera asthe camera calibration image. Since four unknowns need to be calculatedout, at least three images are captured at different angles andlocations, so that f_(u), f_(v), c_(u) and c_(v) may be calculated outlinearly and uniquely using the Zhang Zhengyou calibration algorithm.

That is, in an exemplary embodiment of the present disclosure, the atleast three images may be used as the camera calibration images, and thecamera calibration images may be processed by using the Zhang Zhengyoucalibration algorithm to automatically calculate out the cameraparameter.

Further, the camera calibration images may also be other images than theimage in which the checkerboard is drawn, which is not particularlylimited in this exemplary embodiment.

In Step S20, parallel lane lines are detected to obtain a vanishingpoint of the parallel lane lines according to the detected parallel lanelines.

In an exemplary embodiment of the present disclosure, in the process ofdetecting the parallel lane lines, an image including the parallel lanelines may be first captured. This image may be as shown in FIG. 2.

Next, the image containing the parallel lane lines may be filtered byusing a gradient edge detection operator to generate a gradient image.For example, the image containing the parallel lane lines may befiltered by using a Sobel operator. A Sobel operator in a horizontaldirection and a Sobel operator in a vertical direction are respectivelyas follows:

$\begin{bmatrix}{- 1} & 0 & 1 \\{- 2} & 0 & 2 \\{- 1} & 0 & 1\end{bmatrix},\begin{bmatrix}1 & 2 & 1 \\0 & 0 & 0 \\{- 1} & {- 2} & {- 1}\end{bmatrix}$

Moreover, the process of filtering images using other gradient edgedetection operators (e.g., a Robert operator, a Prewitt operator, etc.)also belongs to the conception of the present disclosure.

Subsequently, an optimal threshold of the gradient image may bedetermined by using a threshold determination algorithm, andbinarization processing is performed on the gradient image to obtain anedge pattern. In an exemplary embodiment of the present disclosure, thethreshold determination algorithm may be, for example, the Otsu method.

Next, a straight line may be detected in this edge pattern using afeature extraction algorithm. In an exemplary embodiment of the presentdisclosure, the feature extraction algorithm may be, for example, theHough transform algorithm.

Next, two straight lines adjacent to each other and having oppositedeflection directions with respect to a height direction of the imagemay be determined as the parallel lane lines. Referring to FIG. 3, fourcandidate straight line segments are detected in a lane line image.However, two adjacent straight line segments in the middle of the imagehave opposite deflection directions with respect to the height directionof the image. That is, in the image, the left straight line segment ofthe two adjacent straight line segments is deflected to the right withrespect to the height direction of the image, and the right straightline segment of the two adjacent straight line segments is deflected tothe left with respect to the height direction of the image, thus the twostraight lines may be regarded as parallel lane lines.

After the parallel lane lines are detected, the two straight lines maybe extended in an upward direction in the image, such that there is anintersection point between the two extended straight lines. Theintersection point is the vanishing point of the lane lines, and acoordinate of the vanishing point in the image may be denoted as (u₀,v₀). FIG. 4 illustrates a schematic diagram of this vanishing point.

In Step S30, a pitch angle of the camera is calculated according to thecamera parameter and the vanishing point.

In the process of calculating the pitch angle φ, first, a spatial pointcoordinate may be denoted as (x, y, z), a corresponding coordinate ofthe midpoint of the image is (u, v), and a camera coordinatetransformation formula may be expressed as follows:

$\begin{bmatrix}u \\v \\1\end{bmatrix} = {{{{k\begin{bmatrix}f_{u} & 0 & c_{u} \\0 & f_{v} & c_{v} \\0 & 0 & 1\end{bmatrix}}\begin{bmatrix}1 & 0 & 0 \\0 & 0 & {- 1} \\0 & 1 & 0\end{bmatrix}}\begin{bmatrix}1 & 0 & 0 \\0 & {\cos\mspace{14mu}(\varphi)} & {{- \sin}\mspace{14mu}(\varphi)} \\0 & {\sin\mspace{14mu}(\varphi)} & {\cos\mspace{14mu}(\varphi)}\end{bmatrix}}\begin{bmatrix}x \\y \\z\end{bmatrix}}$

By simplifying this formula, a formula may be obtained as below:

$\begin{bmatrix}u \\v \\1\end{bmatrix} = {{k\begin{bmatrix}f_{u} & {c_{u}\mspace{14mu}\cos\mspace{14mu}(\varphi)} & {{- c_{u}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} \\0 & {{c_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} & {{{- c_{v}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)}} \\0 & {\cos\mspace{14mu}(\varphi)} & {{- \sin}\mspace{14mu}(\varphi)}\end{bmatrix}}\begin{bmatrix}x \\y \\z\end{bmatrix}}$

Next, the spatial point coordinate (x, y, z) may be set as (0, 1, 0),and then the coordinate of the vanishing point is calculated out:

$\begin{bmatrix}u_{0} \\v_{0} \\1\end{bmatrix} = {k\begin{bmatrix}{c_{u}\mspace{14mu}\cos\mspace{14mu}(\varphi)} \\{{c_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \\{\cos\mspace{14mu}(\varphi)}\end{bmatrix}}$

i.e.,u ₀ =c _(u) , v ₀ =c _(v) −f _(v) tan(φ)

Finally, the pitch angle φ can be calculated out:

$\varphi = {\arctan\left( \frac{c_{v} - v_{0}}{f_{v}} \right)}$

In Step S40, information of an object to be detected in an imagecaptured by the camera is determined.

In an exemplary embodiment of the present disclosure, an object to bedetected, such as a vehicle or a pedestrian, may be first detected in animage captured by the camera based on, for example, an image featureextraction algorithm (e.g., the HOG feature algorithm or the like) forobject detection. As shown in FIG. 5, the detected object may berepresented as a rectangular window. However, the detected object mayalso be represented as other recognizable graphic window, for example, acircle or the like, which is not particularly limited in this exemplaryembodiment.

Next, information of the object to be detected may be determined.Specifically, a coordinate of a preset point of the rectangular windowas well as a width and a height of the rectangular window may bedetermined, whereby the location of the rectangular window in the imagemay be determined. The preset point may be one of four vertices of therectangular window. However, the preset point may also be any pointwithin the rectangular window, which is not specifically limited in thisexemplary embodiment.

Taking an example where the preset point is the upper left vertex of therectangular window, the coordinate (u_(t), v_(t)) of the preset pointand the width w_(t) and the height h_(t) of the rectangular window maybe obtained. That is, according to some embodiments of the presentdisclosure, the coordinate (u_(t), v_(t)) of the preset point and thewidth w_(t) and the height h_(t) of the rectangular window may be usedas information of the object to be detected.

In Step S50, a distance from the object to be detected to the camera anda size of the object to be detected are calculated according to theinformation of the object to be detected, the pitch angle of the camera,and the camera parameter.

First, a distance D from the object to be detected to the camera may becalculated. A coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)), thefollowing formula may be obtained:

$\left( {u_{t\; 2},v_{t\; 2}} \right) = \left( {{u_{t} + \frac{w_{t}}{2}},{v_{t} + h_{t}}} \right)$

By substituting a point (x_(t2), D, −h_(c)) in the space coordinatesystem corresponding to the coordinate (u_(t2), v_(t2)) into the cameracoordinate transformation formula simplified in Step S30, the followingformula may be obtained:

$\begin{bmatrix}u_{t\; 2} \\v_{t\; 2} \\1\end{bmatrix} = {{k\begin{bmatrix}f_{u} & {c_{u}\mspace{14mu}\cos\mspace{14mu}(\varphi)} & {{- c_{u}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} \\0 & {{c_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} & {{{- c_{v}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)}} \\0 & {\cos\mspace{14mu}(\varphi)} & {{- \sin}\mspace{14mu}(\varphi)}\end{bmatrix}}\begin{bmatrix}x_{t\; 2} \\D \\{- h_{c}}\end{bmatrix}}$

By simplifying the above formula, it obtains:v _(t2)(D cos(φ)+h _(c) sin(φ))=(c _(v) cos(φ)−f _(v) sin(φ))D+(c _(v)sin(φ)+f _(v) cos(φ))h _(c)v _(t2)(D+h _(c) tan(φ))=(c _(v) −f _(v) tan(φ))D+(c _(v) tan(φ)+f_(v))h _(c)v _(t2)(D+h _(c) tan(φ))=v ₀ D+(c _(v) tan(φ)+f _(v))h _(c)

The distance D from the object to be detected to the camera may beobtained as:

$D = \frac{{f_{v}h_{c}} + {{h_{c}\left( {c_{v} - v_{t\; 2}} \right)}\mspace{14mu}\tan\mspace{14mu}(\varphi)}}{v_{t\; 2} - v_{0}}$

Next, the height H of the object to be detected may be calculated. Acoordinate of a midpoint of an upper side of the rectangular window inthe image may be denoted as (u_(t2), v_(t2)−h_(t)). By substitutingpoint (x_(t2), D, H−h_(c)) in the corresponding space coordinate systeminto the camera coordinate transformation formula simplified in StepS30, it may obtain:

$\begin{bmatrix}u_{t\; 2} \\{v_{t\; 2} - h_{t}} \\1\end{bmatrix} = {{k\begin{bmatrix}f_{u} & {c_{u}\mspace{14mu}\cos\mspace{14mu}(\varphi)} & {{- c_{u}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} \\0 & {{c_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} & {{{- c_{v}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)}} \\0 & {\cos\mspace{14mu}(\varphi)} & {{- \sin}\mspace{14mu}(\varphi)}\end{bmatrix}}\begin{bmatrix}x_{t\; 2} \\D \\{H - h_{c}}\end{bmatrix}}$

By simplifying the above formula, it obtains:

(v_(t 2) − h_(t))[D − (H − h_(c))  tan   (φ)] = D(c_(v) − f_(v)  tan   (φ)) − (H − h_(c))(f_(v) + c_(v)  tan   (φ))${H - h_{c}} = \frac{D\left( {v_{0} - v_{t\; 2} + h_{t}} \right)}{f_{v} + {\left( {c_{v} - v_{t\; 2} + h_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$$H = {\frac{D\left( {v_{0} - v_{t\; 2} + h_{t}} \right)}{f_{v} + {\left( {c_{v} - v_{t\;}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}} + h_{c}}$

The height H of the object to be detected is obtained.

$H = \frac{h_{t}\left( {D + {h_{c}\mspace{14mu}\tan\mspace{14mu}(\varphi)}} \right)}{f_{v} + {\left( {c_{v} - v_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$

In addition, the width W of the object to be detected may be calculated.At this moment, the camera coordinate transformation formula may be asfollows:

$\begin{bmatrix}u \\v_{t\; 2} \\1\end{bmatrix} = {{k\begin{bmatrix}f_{u} & {c_{u}\mspace{14mu}\cos\mspace{14mu}(\varphi)} & {{- c_{u}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} \\0 & {{c_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} & {{{- c_{v}}\mspace{14mu}\sin\mspace{14mu}(\varphi)} - {f_{v}\mspace{14mu}\cos\mspace{14mu}(\varphi)}} \\0 & {\cos\mspace{14mu}(\varphi)} & {{- \sin}\mspace{14mu}(\varphi)}\end{bmatrix}}\begin{bmatrix}x \\D \\{- h_{c}}\end{bmatrix}}$

By deriving the above formula, it obtains:

$w_{t} = \frac{{Wf}_{u}}{{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}}$

The width W of the object to be detected is obtained:

$W = {\frac{w_{t}}{f_{u}}\left( {{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \right)}$

Through the calculation processes in the above method, a vehicle-mountedauxiliary system may calculate the distances from a vehicle, apedestrian or other obstacle to the camera, as well as the size of thevehicles, the pedestrian or other obstacle in the image captured by thecamera. Furthermore, the method for measuring a distance using avehicle-mounted camera in an exemplary embodiment of the presentdisclosure may further include: transmitting the distances from thevehicle, the pedestrian or other obstacle to the camera, as well as thesizes of the vehicle, the pedestrian or other obstacle to an alarmapparatus, and comparing the calculation result with a preset alarmthreshold. When the calculation result exceeds the preset alarmthreshold, an alarm may be raised to remind a driver to control vehiclespeed and adjust driving direction.

The entire flow of the method for measuring a distance using avehicle-mounted camera of the present disclosure is described withreference to FIG. 6. The method for measuring a distance using avehicle-mounted camera of the present disclosure may be divided intothree method processes. In a first method process, the camera may becalibrated based on the camera calibration image using the ZhangZhengyou calibration algorithm to obtain the camera parameter. In asecond method process, parallel lines may be detected according to theimage captured by the camera, and a vanishing point is determined, and apitch angle of the camera is calculated according to a coordinate of thevanishing point and the camera parameter obtained in the first methodprocess. In a third method process, an object to be detected in theimage may be represented as a rectangular window, and a preset point, awidth and a height of the rectangular window are used as information ofthe object to be detected. Finally, the distance from the object to bedetected to the camera and the size of the object to be detected may becalculated out according to the results obtained in the three methodprocesses.

It is to be noted that although steps of the method in the presentdisclosure are described in a particular order in the accompanyingdrawings, this does not require or imply to execute these stepsnecessarily according to the particular order, or this does not meanthat the expected result cannot be implemented unless all the shownsteps are executed. Additionally or alternatively, some steps may beomitted, a plurality of steps may be combined into one step forexecution, and/or one step may be decomposed into a plurality of stepsfor execution.

Further, an exemplary embodiment further provides an apparatus formeasuring a distance using a vehicle-mounted camera.

FIG. 7 schematically illustrates a block diagram of an apparatus formeasuring a distance using a vehicle-mounted camera according to anexemplary embodiment of the present disclosure. Referring to FIG. 7, theapparatus for measuring a distance using a vehicle-mounted cameraaccording to an exemplary embodiment of the present disclosure mayinclude a camera calibrator 10, a vanishing point obtainer 20, a pitchangle calculator 30, an object to be detected determiner 40, and adistance detector 50.

The camera calibrator 10 may be configured to calibrate a camera basedon camera calibration images to obtain a camera parameter.

The vanishing point obtainer 20 may be configured to detect parallellane lines to obtain a vanishing point of the parallel lane linesaccording to the detected parallel lane lines.

The pitch angle calculator 30 may be configured to calculate a pitchangle of the camera according to the camera parameter and the vanishingpoint.

The object to be detected determiner 40 may be configured to determineinformation of an object to be detected in an image captured by thecamera.

The distance detector 50 may be configured to calculate a distance fromthe object to be detected to the camera and a size of the object to bedetected according to the information of the object to be detected, thepitch angle of the camera, and the camera parameter.

According to this exemplary embodiment of the present disclosure, thecamera calibration images are at least three images obtained bycapturing an image by the camera at different angles and locations.

According to an exemplary embodiment of the present disclosure,calibrating the camera calibration images includes: calibrating thecamera calibration images using a Zhang Zhengyou calibration algorithm.

According to an exemplary embodiment of the present disclosure, thedetecting parallel lane lines includes: capturing an image containingthe parallel lane lines; filtering the image containing the parallellane lines by using a gradient edge detection operator to generate agradient image; determining an optimal threshold of the gradient imageby using a threshold determination algorithm, and performingbinarization processing on the gradient image to obtain an edge pattern;detecting a straight line in the edge pattern using a feature extractionalgorithm; and determining two straight lines adjacent to each other andhaving opposite deflection directions with respect to a height directionof the image as the parallel lane lines.

According to an exemplary embodiment of the present disclosure, theobject to be detected is represented as a rectangular window. Thedetermining of information of the object to be detected in an imagecaptured by the camera includes: determining a coordinate of a presetpoint of the rectangular window corresponding to the object to bedetected in the image captured by the camera as well as a width and aheight of the rectangular window.

According to an exemplary embodiment of the present disclosure, thecamera is installed directly in front of a vehicle.

Functional modules of a program running performance analysis apparatusof the embodiment of the present disclosure are the same as those in theabove method embodiments, and thus detailed descriptions thereof areomitted herein.

In an exemplary embodiment of the present disclosure, there is furtherprovided a computer readable storage medium storing a program productcapable of implementing the above method in the specification. In somepossible embodiments, aspects of the present disclosure may beimplemented as a form of a program product, which includes a programcode. When the program product runs on a terminal device, the programcode is used for enabling the terminal device to perform the stepsdescribed in the above “exemplary method” portions of this specificationaccording to the exemplary embodiments of the present disclosure.

Referring to FIG. 8, a program product 700 configured to implement theabove method is described according to an embodiment of the presentdisclosure. The program product 700 may adopt a portable compact discread-only memory (CD-ROM) and include a program code, and may run on aterminal device such as a personal computer. However, the programproduct of the present disclosure is not limited thereto. In thisdocument, a readable storage medium may be any non-transitory tangiblemedium that can contain or store a program for use by or in connectionwith an instruction execution system, apparatus, or device.

Any combination of one or more readable medium(s), such as anon-transitory computer-readable medium(s), may be utilized by theprogram product. The readable medium may be a readable signal medium ora readable storage medium. The readable storage medium may be, forexample, but not limited to, an electronic, magnetic, optical,electromagnetic, infrared, or semiconductor system, apparatus, ordevice, or any suitable combination of the foregoing. More specificexamples (a non-exhaustive list) of the readable storage medium includethe following: an electrical connection having one or more wires, aportable diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), an optical fiber, a portable compact disc read-onlymemory (CD-ROM), an optical storage device, a magnetic storage device,or any suitable combination of the foregoing.

A computer readable signal medium may include a propagated data signalwith readable program code embodied therein, in baseband or as part of acarrier wave. Such propagated data signal may take a variety of forms,including, but not limited to, electro-magnetic, optical, or anysuitable combination thereof. A readable signal medium may be anyreadable medium that is not a readable storage medium and that cancommunicate, propagate, or transport a program for use by or inconnection with an instruction execution system, apparatus, or device.

Program code embodied on a readable medium may be transmitted using anyappropriate medium, including but not limited to wireless, wireline,optical fiber cable, RF, etc., or any suitable combination of theforegoing.

Program code for carrying out operations of the present disclosure maybe written in any combination of one or more programming languages,including an object-oriented programming language such as Java, C++, orthe like and conventional procedural programming languages, such as “C”programming language or similar programming languages. The program codemay be executed entirely on a user's computing device, partly on theuser's computing device, as a stand-alone software package, partly onthe user's computing device and partly on a remote computing device orentirely on the remote computing device or a server. In a scenarioinvolved with the remote computing device, the remote computing devicemay be coupled to the user's computing device through any type ofnetwork, including a local area network (LAN) or a wide area network(WAN), or may be coupled to an external computing device (for example,through the Internet using an Internet Service Provider).

In an exemplary embodiment of the present disclosure, there is furtherprovided an electronic device capable of implementing the above method.

As will be appreciated by one skilled in the art, various aspects of thepresent disclosure may be embodied as a system, method, non-transitorycomputer-readable medium, or program product. Accordingly, variousaspects of the present disclosure may take the form of an entirelyhardware implementation, an entirely software implementation (includingfirmware, micro-code, etc.) or an implementation combining software andhardware aspects, that may all generally be referred to herein as a“circuit,” “module”, or “system.”

An electronic device 800 according to an embodiment of the presentdisclosure is described below with reference to FIG. 9. The electronicdevice 800 as shown in FIG. 9 is merely an example, and no limitationshould be imposed on functions or scope of use of embodiments of thepresent disclosure.

As shown in FIG. 9, the electronic device 800 is shown in form of ageneral-purpose computing device. Components of the electronic device800 may include, but are not limited to: at least one processing unit810, at least one storage unit 820, a bus 830 connecting differentsystem components (including a storage unit 820 and a processing unit810), and a display unit 840.

The storage unit stores a program code, which may be executed by theprocessing unit 810, such that the processing unit 810 performs stepsdescribed in the “exemplary method” portions of the specificationaccording to exemplary embodiments of the present disclosure. Forexample, the processing unit 810 may perform the steps as shown in FIG.1, including Step S10: calibrating a camera based on camera calibrationimages to obtain a camera parameter; Step S20: detecting parallel lanelines to obtain a vanishing point of the parallel lane lines accordingto the detected parallel lane lines; Step S30: calculating a pitch angleof the camera according to the camera parameter and the vanishing point;Step S40: determining information of an object to be detected in animage captured by the camera; and Step S50: calculating a distance fromthe object to be detected to the camera and a size of the object to bedetected according to the information of the object to be detected, thepitch angle of the camera, and the camera parameter.

The storage unit 820 may include readable media in form of volatilestorage unit, such as a random access memory (RAM) 8201 and/or a cachememory 8202. Furthermore, the storage unit 820 may further include aread-only memory (ROM) 8203.

The storage unit 820 may include a program/utility tool 8204 having agroup of (at least one) program module(s) 8205. The program modules 8205include, but are not limited to: an operating system, one or moreapplications, other program modules and program data. Each or a certaincombination of these examples may include implementation of networkenvironment.

The bus 830 may represent one or more of a plurality of bus structures,including a memory bus or memory controller, a peripheral bus, anaccelerated graphics port, a processing unit or a local bus using anybus structure among the plurality of bus structures.

The electronic device 800 may communicate with one or more peripheraldevices 900 (such as a keyboard, a pointing device, a Bluetooth device,etc.), and also may communicate with one or more devices allowing a userto interact with the electronic device 800, and/or may communicate withany device (for example, a router, a modem and so on) allowing theelectronic device 800 to communicate with one or more other computingdevices. This communication may be implemented by means of aninput/output (I/O) interface 850. Moreover, the electronic device 800also may communicate with one or more networks (for example, a localarea network (LAN), a wide area network (WAN) and/or a public networksuch as Internet) via a network adapter 860. As shown, the networkadapter 860 communicates with other modules of the electronic device 800through the bus 830. It should be understood that although not shown inthe figures, other hardware and/or software modules that may be used incombination with the electronic device 800, includes but are not limitedto: microcode, a device driver, a redundancy processing unit, anexternal disk drive array, a redundant array of independent disks (RAID)system, a tape drive and a data backup and storage system, etc.

With description of the above embodiments, it will be readily understoodby those skilled in the art that the exemplary embodiments describedherein may be implemented by software or may be implemented by means ofsoftware in combination with necessary hardware. Thus, the technicalsolution according to the embodiments of the present disclosure may beembodied in form of a software product which may be stored in anonvolatile storage medium (which may be CD-ROM, USB flash disk, mobilehard disk and the like) or on network, including a number ofinstructions for enabling a computing device (which may be a personalcomputer, a server, a terminal device, or a network device and the like)to perform the method according to the embodiments of the presentdisclosure.

Moreover, the above accompanying drawings are merely illustrativedescription of processes included in the method according to theexemplary embodiments of the present disclosure and are not intended tolimit the present disclosure. It is understandable that the processesshown in the above accompanying drawings do not indicate or limit timesequences of these processes. Furthermore, it is understandable thatthese processes may be executed, for example, synchronously orasynchronously in a plurality of modules.

It is to be noted that although a plurality of modules or units of thedevice for action execution have been mentioned in the above detaileddescription, this partition is not compulsory. Actually, according toembodiments of the present disclosure, features, and functions of two ormore modules or units as described above may be embodied in one moduleor unit. Conversely, features and functions of one module or unit asdescribed above may be further embodied in more modules or units.

Other embodiments of the present disclosure will be apparent to thoseskilled in the art from consideration of the specification and onpractice of the present disclosure disclosed here. This application isintended to cover any variations, uses, or adaptations of the presentdisclosure following the general principles thereof and including suchdepartures from the present disclosure as come within known or customarypractice in the art. It is intended that the specification andembodiments be considered as exemplary only, with a true scope andspirit of the present disclosure being indicated by the followingclaims.

It will be appreciated that the present disclosure is not limited to theexact construction that has been described above and illustrated in theaccompanying drawings, and that various modifications and changes can bemade without departing from the scope thereof. It is intended that thescope of the present disclosure only be limited by the appended claims.

What is claimed is:
 1. A method for measuring a distance using avehicle-mounted camera, comprising: calibrating a camera based on cameracalibration images to obtain a camera parameter, wherein the cameracalibration images are at least three images obtained by capturing anobjective image by the camera at different angles and locations;detecting parallel lane lines in an image captured by the camera toobtain a vanishing point of the parallel lane lines according todetected parallel lane lines; calculating a pitch angle of the cameraaccording to the camera parameter and the vanishing point; determininginformation of an object to be detected in the image captured by thecamera; and calculating a distance from the object to be detected to thecamera and a size of the object to be detected according to theinformation of the object to be detected, the pitch angle of the camera,and the camera parameter, wherein the image captured by the cameracontains the parallel lane lines.
 2. The method for measuring thedistance using the vehicle-mounted camera according to claim 1, wherein:calibrating of the camera based on the camera calibration images toobtain the camera parameter comprises calibrating the camera calibrationimages using a Zhang Zhengyou calibration algorithm.
 3. The method formeasuring the distance using the vehicle-mounted camera according toclaim 1, wherein detecting the parallel lane lines comprises: filteringthe image containing the parallel lane lines by using a gradient edgedetection operator to generate a gradient image; determining an optimalthreshold of the gradient image by using a threshold determinationalgorithm, and performing binarization processing on the gradient imageto obtain an edge pattern; detecting a straight line in the edge patternusing a feature extraction algorithm; and determining two straight linesadjacent to each other and having opposite deflection directions withrespect to a height direction of the image as the parallel lane lines.4. The method for measuring the distance using the vehicle-mountedcamera according to claim 1, wherein: the object to be detected isrepresented as a rectangular window; and the determining of informationof an object to be detected in the image captured by the cameracomprises determining a coordinate of an arbitrary point of therectangular window corresponding to the object to be detected in theimage captured by the camera and a width and a height of the rectangularwindow.
 5. The method for measuring the distance using thevehicle-mounted camera according to claim 1, wherein a coordinate of thevanishing point in the image captured by the camera is denoted as (u₀,v₀), and the pitch angle of the camera is calculated based on a formulaas below:$\varphi = {\arctan\left( \frac{c_{v} - v_{0}}{f_{v}} \right)}$ whereinφ represents the pitch angle, f_(v) represents a focal length of acamera head of the camera, and c_(v) represents a location coordinate ofan optical center of the camera head.
 6. The method for measuring thedistance using the vehicle-mounted camera according to claim 4, whereinthe size of the object to be detected comprises a height and a width ofthe object to be detected.
 7. The method for measuring the distanceusing the vehicle-mounted camera according to claim 4, wherein thedistance from the object to be detected to the camera is calculatedbased on a formula as below:$D = \frac{{f_{v}h_{c}} + {{h_{c}\left( {c_{v} - v_{t\; 2}} \right)}\mspace{14mu}\tan\mspace{14mu}(\varphi)}}{v_{t\; 2} - v_{0}}$wherein D represents the distance from the object to be detected to thecamera, φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, c_(v) represents a location coordinate ofan optical center of the camera head, and a coordinate of a midpoint ofa lower side of the rectangular window in the image is denoted as(u_(t2), v_(t2)) and a corresponding spatial point coordinate is denotedas (x_(t2), D, −h_(c)), and a coordinate of the vanishing point in theimage captured by the camera is denoted as (u₀, v₀).
 8. The method formeasuring the distance using the vehicle-mounted camera according toclaim 6, wherein the height of the object to be detected is calculatedbased on a formula as below:$H = \frac{h_{t}\left( {D + {h_{c}\mspace{14mu}\tan\mspace{14mu}(\varphi)}} \right)}{f_{v} + {\left( {c_{v} - v_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$wherein H represents the height of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, h_(t) represents the height of therectangular window, f_(v) represents a focal length of a camera head ofthe camera, c_(v) represents a location coordinate of an optical centerof the camera head, the coordinate of the arbitrary point is denoted as(u_(t), v_(t)), and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).
 9. The method for measuring the distance using thevehicle-mounted camera according to claim 6, wherein the width of theobject to be detected is calculated based on a formula as below:$W = {\frac{w_{t}}{f_{u}}\left( {{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \right)}$wherein W represents the width of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, f_(u) represents a focal length of a camerahead of the camera, w_(t) represents the width of the rectangularwindow, and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).
 10. A non-transitory computer-readable storage medium storing acomputer program thereon, wherein when the computer program is executedby a processor, a method for measuring a distance using avehicle-mounted camera is implemented, the method for measuring thedistance using the vehicle-mounted camera comprising: calibrating acamera based on camera calibration images to obtain a camera parameter,wherein the camera calibration images are at least three images obtainedby capturing an objective image by the camera at different angles andlocations; detecting parallel lane lines in an image captured by thecamera to obtain a vanishing point of the parallel lane lines accordingto detected parallel lane lines; calculating a pitch angle of the cameraaccording to the camera parameter and the vanishing point; determininginformation of an object to be detected in the image captured by thecamera; and calculating a distance from the object to be detected to thecamera and a size of the object to be detected according to theinformation of the object to be detected, the pitch angle of the camera,and the camera parameter, wherein the image captured by the cameracontains the parallel lane lines.
 11. An electronic device, comprising:at least one hardware processor; and a memory configured to storeexecutable instructions of the at least one hardware processor; whereinthe at least one hardware processor is configured to perform a methodfor measuring a distance using a vehicle-mounted camera by executing theexecutable instructions comprising: calibrating a camera based on cameracalibration images to obtain a camera parameter, wherein the cameracalibration images are at least three images obtained by capturing anobjective image by the camera at different angles and locations;detecting parallel lane lines in an image captured by the camera toobtain a vanishing point of the parallel lane lines according todetected parallel lane lines; calculating a pitch angle of the cameraaccording to the camera parameter and the vanishing point; determininginformation of an object to be detected in the image captured by thecamera; and calculating a distance from the object to be detected to thecamera and a size of the object to be detected according to theinformation of the object to be detected, the pitch angle of the camera,and the camera parameter, wherein the image captured by the cameracontains the parallel lane lines.
 12. The electronic device according toclaim 11, wherein: calibrating of the camera based on the cameracalibration images to obtain the camera parameter comprises calibratingthe camera calibration images using a Zhang Zhengyou calibrationalgorithm.
 13. The electronic device according to claim 11, whereindetecting the parallel lane lines comprises: filtering the imagecontaining the parallel lane lines by using a gradient edge detectionoperator to generate a gradient image; determining an optimal thresholdof the gradient image by using a threshold determination algorithm, andperforming binarization processing on the gradient image to obtain anedge pattern; detecting a straight line in the edge pattern using afeature extraction algorithm; and determining two straight linesadjacent to each other and having opposite deflection directions withrespect to a height direction of the image as the parallel lane lines.14. The electronic device according to claim 11, wherein: the object tobe detected is represented as a rectangular window; and the determiningof information of an object to be detected in the image captured by thecamera comprises: determining a coordinate of an arbitrary point of therectangular window corresponding to the object to be detected in theimage captured by the camera and a width and a height of the rectangularwindow.
 15. The electronic device according to claim 11, wherein acoordinate of the vanishing point in the image captured by the camera isdenoted as (u₀, v₀), and the pitch angle of the camera is calculatedbased on a formula as below:$\varphi = {\arctan\left( \frac{c_{v} - v_{0}}{f_{v}} \right)}$ whereinφ represents the pitch angle, f_(v) represents a focal length of acamera head of the camera, and c_(v) represents a location coordinate ofan optical center of the camera head.
 16. The electronic deviceaccording to claim 14, wherein the size of the object to be detectedcomprises a height and a width of the object to be detected.
 17. Theelectronic device according to claim 14, wherein the distance from theobject to be detected to the camera is calculated based on a formula asbelow:$D = \frac{{f_{v}h_{c}} + {{h_{c}\left( {c_{v} - v_{t\; 2}} \right)}\mspace{14mu}\tan\mspace{14mu}(\varphi)}}{v_{t\; 2} - v_{0}}$wherein D represents the distance from the object to be detected to thecamera, φ represents the pitch angle, f_(v) represents a focal length ofa camera head of the camera, c_(v) represents a location coordinate ofan optical center of the camera head, and a coordinate of a midpoint ofa lower side of the rectangular window in the image is denoted as(u_(t2), v_(t2)) and a corresponding spatial point coordinate is denotedas (x_(t2), D, −h_(c)), and a coordinate of the vanishing point in theimage captured by the camera is denoted as (u₀, v₀).
 18. The electronicdevice according to claim 16, wherein the height of the object to bedetected is calculated based on a formula as below:$H = \frac{h_{t}\left( {D + {h_{c}\mspace{14mu}\tan\mspace{14mu}(\varphi)}} \right)}{f_{v} + {\left( {c_{v} - v_{t}} \right)\mspace{14mu}\tan\mspace{14mu}(\varphi)}}$wherein H represents the height of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, h_(t) represents the height of therectangular window, f_(v) represents a focal length of a camera head ofthe camera, c_(v) represents a location coordinate of an optical centerof the camera head, the coordinate of the arbitrary point is denoted as(u_(t), v_(t)), and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)), and wherein the width of the object to be detected iscalculated based on a formula as below:$W = {\frac{w_{t}}{f_{u}}\left( {{D\mspace{14mu}\cos\mspace{14mu}(\varphi)} + {h_{c}\mspace{14mu}\sin\mspace{14mu}(\varphi)}} \right)}$wherein W represents the width of the object to be detected, Drepresents the distance from the object to be detected to the camera, φrepresents the pitch angle, f_(u) represents a focal length of a camerahead of the camera, w_(t) represents the width of the rectangularwindow, and a coordinate of a midpoint of a lower side of therectangular window in the image is denoted as (u_(t2), v_(t2)) and acorresponding spatial point coordinate is denoted as (x_(t2), D,−h_(c)).
 19. The non-transitory computer-readable storage mediumaccording to claim 10, wherein: calibrating of the camera based on thecamera calibration images to obtain the camera parameter comprisescalibrating the camera calibration images using a Zhang Zhengyoucalibration algorithm.
 20. The non-transitory computer-readable storagemedium according to claim 10, wherein detecting the parallel lane linescomprises: filtering the image containing the parallel lane lines byusing a gradient edge detection operator to generate a gradient image;determining an optimal threshold of the gradient image by using athreshold determination algorithm, and performing binarizationprocessing on the gradient image to obtain an edge pattern; detecting astraight line in the edge pattern using a feature extraction algorithm;and determining two straight lines adjacent to each other and havingopposite deflection directions with respect to a height direction of theimage as the parallel lane lines.